/*
 * Copyright 2017 Baiyyy
 * @(#)ColdStorageService.java
 */

package com.byyy.ccts.modules.ysjl.service.impl;

import com.baomidou.mybatisplus.mapper.Wrapper;
import com.byyy.ccts.core.common.service.impl.CommonServiceImpl;
import com.byyy.ccts.core.query.data.Page;
import com.byyy.ccts.core.query.data.PageImpl;
import com.byyy.ccts.core.query.data.Pageable;
import com.byyy.ccts.core.query.data.Queryable;
import com.byyy.ccts.core.query.parse.QueryToWrapper;
import com.byyy.ccts.core.query.wrapper.EntityWrapper;
import com.byyy.ccts.modules.ysjl.entity.YsjlActivity;
import com.byyy.ccts.modules.ysjl.entity.YsjlLog;
import com.byyy.ccts.modules.ysjl.mapper.YsjlLogMapper;
import com.byyy.ccts.modules.ysjl.service.IYsjlLogService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by DELL on 2018-6-13.
 */
@Transactional
@Service("ysjlLogService")
public class YsjlLogService extends CommonServiceImpl<YsjlLogMapper, YsjlLog> implements IYsjlLogService {

    @Override
    public Page<YsjlLog> logPageList(Queryable queryable, EntityWrapper<YsjlLog> wrapper) {
        QueryToWrapper<YsjlLog> queryToWrapper = new QueryToWrapper<>();
        // 排序问题
        queryToWrapper.parseCondition(wrapper, queryable);
        queryToWrapper.parseSort(wrapper, queryable);
        Pageable pageable = queryable.getPageable();
        com.baomidou.mybatisplus.plugins.Page<YsjlLog> page = new com.baomidou.mybatisplus.plugins.Page<YsjlLog>(
                pageable.getPageNumber(), pageable.getPageSize());
        com.baomidou.mybatisplus.plugins.Page<YsjlLog> content = this.listPage(page, wrapper);
        return new PageImpl<YsjlLog>(content.getRecords(), queryable.getPageable(), content.getTotal());
    }

    public com.baomidou.mybatisplus.plugins.Page<YsjlLog> listPage(com.baomidou.mybatisplus.plugins.Page<YsjlLog> page, Wrapper<YsjlLog> wrapper) {
        page.setRecords(baseMapper.querylogPageList(page, wrapper));
        return page;
    }

    @Override
    public List<YsjlLog> queryMyListByActivityId(String activityId, String userId) {
        return this.baseMapper.queryMyListByActivityId(activityId, userId);
    }

}
